home *** CD-ROM | disk | FTP | other *** search
/ Knitting Made Easy / Knitting.iso / App / main.dxr / behaviors_100_Video slider2.ls < prev    next >
Encoding:
Text File  |  2002-03-27  |  6.0 KB  |  170 lines

  1. property pDuration, pMovieTime, videoSprite, horizontal, extentSprite, hiliteMember, tracking, newLocH, newLocV, sending, dynamic, style, Addressee, name, notify_list, min, max, valrange, minScreen, maxScreen, currentScreenVal, extentlength, CurrentVal
  2.  
  3. on getPropertyDescriptionList
  4.   if the currentSpriteNum = 0 then
  5.     memdefault = 0
  6.   else
  7.     memref = the member of sprite the currentSpriteNum
  8.     castLibNum = memref.castLibNum
  9.     memdefault = member(memref.memberNum + 1, castLibNum)
  10.   end if
  11.   description = [:]
  12.   addProp(description, #videoSprite, [#default: 1, #format: #integer, #comment: "Video Sprite:"])
  13.   addProp(description, #extentSprite, [#default: 1, #format: #integer, #comment: "Extent Sprite:"])
  14.   addProp(description, #hiliteMember, [#default: memdefault, #format: #graphic, #comment: "Hilite Member:"])
  15.   addProp(description, #horizontal, [#default: 1, #format: #boolean, #comment: "Horizontal (if not vertical):"])
  16.   addProp(description, #dynamic, [#default: 1, #format: #boolean, #comment: "Dynamic:"])
  17.   return description
  18. end
  19.  
  20. on getBehaviorDescription
  21.   return "Drag to slider 'handle' to enable control of video play time.  Requires additional 'extent' member which limits the handle travel range." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Video Sprite - Enter the number of sprite channel in which video is displayed." & RETURN & "ΓÇó Extent Sprite -  Enter the number of sprite channel that contains the 'extent' sprite." & RETURN & "ΓÇó Hilite Member -  Member to display while handle is being dragged." & RETURN & "ΓÇó Horizontal - If set, orient extent sprite horizontally, if not set orient vertically." & RETURN & "ΓÇó Dynamic - If set, video time will be updated while handle is dragged, else when handle is released."
  22. end
  23.  
  24. on compute_val me
  25.   val = 0.0
  26.   val = float(me.currentScreenVal) / float(me.extentlength)
  27.   val = val * me.valrange
  28.   val = val + me.min
  29.   return val
  30. end
  31.  
  32. on send_the_val me, val
  33.   global videoStart
  34.   pMovieTime = (val * pDuration) + videoStart
  35.   videopause(sprite(videoSprite))
  36.   videoseek(sprite(videoSprite), pMovieTime)
  37.   videopause(sprite(videoSprite))
  38.   videoplay(sprite(videoSprite))
  39.   videopause(sprite(videoSprite))
  40.   videoplay(sprite(videoSprite))
  41.   set the member of sprite 4 to member(28, 5)
  42. end
  43.  
  44. on beginSprite me
  45.   global videoStart, videoEnd
  46.   pDuration = videoEnd - videoStart
  47.   me.min = 0.0
  48.   me.max = 1.0
  49.   me.sending = 1
  50.   handle = me.spriteNum
  51.   me.tracking = 0
  52.   me.newLocH = the locH of sprite handle
  53.   me.newLocV = the locV of sprite handle
  54.   if me.horizontal then
  55.     me.newLocV = the locV of sprite me.extentSprite
  56.     me.minScreen = the left of sprite me.extentSprite
  57.     me.maxScreen = the right of sprite me.extentSprite
  58.   else
  59.     me.newLocH = the locH of sprite me.extentSprite
  60.     me.minScreen = the left of sprite me.extentSprite
  61.     me.maxScreen = the right of sprite me.extentSprite
  62.   end if
  63.   set the locH of sprite handle to me.newLocH
  64.   set the locV of sprite handle to me.newLocV
  65.   me.valrange = me.max - me.min
  66.   me.extentlength = me.maxScreen - me.minScreen
  67.   if me.sending = 0 then
  68.     me.dynamic = 0
  69.   end if
  70. end
  71.  
  72. on prepareFrame me
  73.   global videoStart
  74.   if tracking then
  75.     handle = me.spriteNum
  76.     extent = me.extentSprite
  77.     if me.horizontal then
  78.       me.newLocH = the mouseH
  79.       me.newLocV = the locV of sprite extent
  80.       if me.newLocH < the left of sprite extent then
  81.         me.newLocH = the left of sprite extent
  82.       end if
  83.       if me.newLocH > the right of sprite extent then
  84.         me.newLocH = the right of sprite extent
  85.       end if
  86.       me.currentScreenVal = me.newLocH - me.minScreen
  87.     else
  88.       me.newLocH = the locH of sprite extent
  89.       me.newLocV = the mouseV
  90.       if me.newLocV < the top of sprite extent then
  91.         me.newLocV = the top of sprite extent
  92.       end if
  93.       if me.newLocV > the bottom of sprite extent then
  94.         me.newLocV = the bottom of sprite extent
  95.       end if
  96.       me.currentScreenVal = me.newLocV - me.minScreen
  97.     end if
  98.     set the locH of sprite handle to me.newLocH
  99.     set the locV of sprite handle to me.newLocV
  100.     if me.dynamic then
  101.       send_the_val(me, compute_val(me))
  102.     end if
  103.   else
  104.     x = float(sprite(videoSprite).currentTime - videoStart) / float(pDuration)
  105.     handle = me.spriteNum
  106.     extent = me.extentSprite
  107.     if me.horizontal then
  108.       ScreenX = the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
  109.       me.newLocH = ScreenX
  110.       me.newLocV = the locV of sprite extent
  111.       if me.newLocH < the left of sprite extent then
  112.         me.newLocH = the left of sprite extent
  113.       end if
  114.       if me.newLocH > the right of sprite extent then
  115.         me.newLocH = the right of sprite extent
  116.       end if
  117.       me.currentScreenVal = me.newLocH - me.minScreen
  118.     else
  119.       ScreenY = the top of sprite extent + (x * (the bottom of sprite extent - the top of sprite extent))
  120.       me.newLocH = the locH of sprite extent
  121.       me.newLocV = ScreenY
  122.       if me.newLocV < the top of sprite extent then
  123.         me.newLocV = the top of sprite extent
  124.       end if
  125.       if me.newLocV > the bottom of sprite extent then
  126.         me.newLocV = the bottom of sprite extent
  127.       end if
  128.       me.currentScreenVal = me.newLocV - me.minScreen
  129.     end if
  130.     set the locH of sprite handle to me.newLocH
  131.     set the locV of sprite handle to me.newLocV
  132.   end if
  133. end
  134.  
  135. on mouseDown me
  136.   videopause(sprite(videoSprite))
  137.   tracking = 1
  138.   temp = the member of sprite me.spriteNum
  139.   set the member of sprite the spriteNum of me to member(me.hiliteMember)
  140.   me.hiliteMember = temp
  141. end
  142.  
  143. on mouseUp me
  144.   tracking = 0
  145.   temp = the member of sprite me.spriteNum
  146.   set the member of sprite the spriteNum of me to member(me.hiliteMember)
  147.   me.hiliteMember = temp
  148.   if me.sending then
  149.     x = compute_val(me)
  150.     send_the_val(me, x)
  151.   end if
  152. end
  153.  
  154. on mouseUpOutSide me
  155.   tracking = 0
  156.   temp = the member of sprite me.spriteNum
  157.   set the member of sprite the spriteNum of me to member(me.hiliteMember)
  158.   me.hiliteMember = temp
  159.   if me.sending then
  160.     x = compute_val(me)
  161.     send_the_val(me, x)
  162.   end if
  163. end
  164.  
  165. on mouseEnter me
  166. end
  167.  
  168. on mouseLeave me
  169. end
  170.